<template>
    <div :class="{'hid-slider': !isOpen}" class="app-container table-wrapper">
        <split-pane @resize="resize" :min-percent="2" :default-percent="defaultPercent" :max-percent="30" split="vertical" ref="split">
            <template slot="paneL">
                <slider :is-open="isOpen" class="slider-wrapper" @toggleSlider="toggleSlider">
                    <el-tabs v-model="leftTabName" @tab-click="handleLeftTabClick" class="left-tab">
                        <el-tab-pane label="查询管理" name="first">
                            <el-form ref="form" :model="filterData" label-width="10px">
                                <el-form-item label="">
                                    <h3>成立日期起始</h3>
                                    <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="filterData._INTERVAIL_MIN_ORGDEPARTMENT_CREATEDATE"/>
                                </el-form-item>
                                <el-form-item label="">
                                    <h3>成立日期结束</h3>
                                    <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="filterData._INTERVAIL_MAX_ORGDEPARTMENT_CREATEDATE"/>
                                </el-form-item>
                                <el-form-item label="">
                                    <h3>组织级别</h3>
                                    <el-select v-model="filterData.ORGDEPARTMENT_DEPGRADE" placeholder="请选择">
                                        <!-- dictTypeCode -->
                                        <el-option
                                            v-for="item in dictValues['sql|sql13']"
                                            :key="item.code"
                                            :label="item.name"
                                            :value="item.code"/>
                                    </el-select>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="searchForm()">查询</el-button>
                                    <el-button @click="resetForm()">重置</el-button>
                                </el-form-item>
                            </el-form>
                        </el-tab-pane>
                        <el-tab-pane label="入职管理树" name="second">
                            <el-tree
                                :props="treeProps"
                                :load="loadNode"
                                node-key="ORGVORGANIZATION_ID"
                                lazy
                                :filter-node-method="filterNode"
                                show-checkbox/>
                        </el-tab-pane>
                    </el-tabs>
                </slider>
            </template>
            <template slot="paneR">
                <table-container
                    ref="table685"
                    :form-id="formId"
                    :settings="settings"
                    :filter-data="filterData"
                    :common-placeholder="commonPlaceholder"
                    :columns="columns"
                    :col-headers="colHeaders"
                    :height-grade="heightGrade"
                    :true-table-date="trueTableDate"/>
                <!-- 分页 -->
                <div class="pagination-container" style="margin-top: 10px;position: absolute;bottom: 20px;">
                    <el-pagination
                        :current-page="pager.offset"
                        :page-sizes="[20, 30, 50, 100]"
                        :page-size="pager.limit"
                        :total="totalData"
                        layout="total, sizes, prev, pager, next, jumper"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"/>
                </div>
            </template>
        </split-pane>
    </div>
</template>

<script>
import slider from '@/components/table/slider'
import tableContainer from '@/components/table/handsontable-container'
import { queryTreeSolution, batchSaveButtonSave, removeData } from '@/api/api'
import { columnType } from '@/common/utils/index'
import pagination from '@/mixins/pagination'
import tableInterface from '@/mixins/handsontableInterface'

export default {
    name: 'handsontable',
    components: { slider, tableContainer },
    mixins: [pagination, tableInterface],
    data() {
        return {
            formId: '685',
            buttonId: '7283',
            // 没有侧边为false
            isOpen: true,
            defaultPercent: 20,
            // tab默认显示哪个
            leftTabName: 'second',
            // 树的对应的显示字段
            treeProps: {
                label: 'ORGVORGANIZATION_cname',
                isLeaf: 'isLeaf'
            },
            // 树的查询条件
            tree: {
                ORGVORGANIZATION_ID: null,
                lv: null
            },
            dictValues: {},
            commonFilter: '',
            commonPlaceholder: '人数,部门名称,部门编码',
            commonFilterArr: ['DEPVPEOPLECOUNT_NUM', 'ORGDEPARTMENT_CNAME', 'ORGDEPARTMENT_DEPCODE'],
            filterData: {
                DEPVPEOPLECOUNT_NUM: '',
                ORGDEPARTMENT_CNAME: '',
                ORGDEPARTMENT_DEPCODE: '',
                ORGDEPARTMENT_DEPGRADE: '',
                _INTERVAIL_MAX_ORGDEPARTMENT_CREATEDATE: '',
                _INTERVAIL_MIN_ORGDEPARTMENT_CREATEDATE: ''
            },
            settings: {
                // 数据
                data: [],
                // 铺满设置的宽度
                stretchH: 'all',
                // width: 1006,
                // height: 487,
                autoWrapRow: true,
                // maxRows: 22,
                // fixedRowsTop: 2,
                // fixedRowsBottom: 2,
                // fixedColumnsLeft: 3,
                // 列头
                rowHeaders: true,
                // 列排序
                columnSorting: {
                    indicator: true
                },
                autoColumnSize: {
                    samplingRatio: 23
                },
                language: 'zh-CN',
                // 可以右键
                // contextMenu: true,
                contextMenu: {
                    items: {
                        'row_above': {},
                        'row_below': {},
                        'col_left': {},
                        'col_right': {},
                        'remove_row': {},
                        'remove_col': {},
                        'alignment': {},
                        'make_read_only': {},
                        'copy': {},
                        'cut': {}
                    }
                },
                mergeCells: true,
                // 行列可以改变宽高
                manualRowResize: true,
                manualColumnResize: true,
                // 行列可以拖动
                manualRowMove: true,
                manualColumnMove: true,
                dropdownMenu: true,
                filters: true,
                afterChange: (changes, source) => {
                    // this.updatePlayerList = this.$refs.table685.getSourceData()
                    console.log(changes)
                    console.log(source)
                    if (changes) {
                        const changeData = []
                        changes.forEach(([row, prop, oldValue, newValue]) => {
                            console.log(temp)
                            const temp = {
                                'param': Object.assign({}, this.trueTableDate[row]),
                                'formId': this.formId,
                                'buttonId': this.buttonId,
                                'paramsMap': {}
                            }
                            changeData.push(temp)
                            // 正则判断
                            // let phoneReg = /^1(3|4|5|7|8)\d{9}$/
                            // if(prop == 'phone'){ //phone是我需要判断的字段
                            //     if( phoneReg.test(newValue)){
                            //         console.log(true);
                            //     } else{
                            //         console.log(false);
                            //     }
                            // }
                        })
                        this._batchSaveButtonSave(changeData)
                    }
                },
                afterOnCellMouseUp: function(event, coords, TD) {
                    // console.log(event, coords, TD)
                },
                beforeFilter: (conditionsStack) => {
                    if (conditionsStack.length > 0) {
                        return false
                    }
                },
                afterFilter: (conditionsStack) => {
                    console.log(conditionsStack)
                    if (conditionsStack.length > 0) {
                        this.handleHeightGrade(conditionsStack)
                    }
                },
                afterLoadData: (initialLoad) => {
                    console.log(initialLoad)
                },
                beforeRemoveRow: (index, amount, physicalRows, source) => {
                    console.log(index, amount, physicalRows, source)
                    if (physicalRows.length > 0) {
                        this.handleRemoveRow(physicalRows)
                    }
                }
            },
            columns: [],
            heightGrade: [],
            showRowColumn: [

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPCODE',
                    columnName: '组织编码',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_CNAME',
                    columnName: '组织名称',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'edit',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'DEP_V_PEOPLECOUNT',
                    columnId: 'DEPVPEOPLECOUNT_NUM',
                    columnName: '人数',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'readonly',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_ENAME',
                    columnName: '组织简称',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPTYPE',
                    columnName: '组织类型',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'sql|sql286',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPGRADE',
                    columnName: '组织级别',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'sql|sql13',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPAREA',
                    columnName: '机构区域',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'dict|COMPAREA',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_ISALLOW',
                    columnName: '是否享受海岛津贴',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'dict|att_yes_no',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_HANGLEADER',
                    columnName: '挂片领导',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'sql|sql12',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_ISPROTECT',
                    columnName: '是否保护期',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'dict|att_yes_no',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPKIND',
                    columnName: '业务条线',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'sql|sql247',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DEPCOST',
                    columnName: '成本中心',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'dict|DEPCOST',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_COMPID',
                    columnName: '所属公司',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'sql|comPid',
                        comboboxMultiselect: '0',
                        comboboxShownullitem: '0',
                        comboboxIsSearch: ''
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_PARENTID',
                    columnName: '上级组织',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '请选择...',
                        dictTypeCode: 'sql|sql6',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 日期选择框

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_CREATEDATE',
                    columnName: '成立日期',
                    columnType: '6',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'edit',
                    columnTypeDetail: {
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        datepickerFormat: 'yyyy-MM-dd />'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_LEADER',
                    columnName: '分管领导',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'sql|sql12',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_LEADERSHIP',
                    columnName: '协管领导',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'sql|sql12',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_XORDER',
                    columnName: '排序',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_REMARK',
                    columnName: '备注',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_DISABLEDDATE',
                    columnName: '失效日期',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 日期选择框

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_UPDATETIME',
                    columnName: '最近修改日期',
                    columnType: '6',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'edit',
                    columnTypeDetail: {
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        datepickerFormat: 'yyyy-MM-dd />'
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_ISFININSTITU',
                    columnName: '是否人行金融机构',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '',
                        dictTypeCode: 'dict|att_yes_no',
                        comboboxMultiselect: 'N',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_FININSTITU',
                    columnName: '人行金融机构代码',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_WEBNUM',
                    columnName: '网点号',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 文本

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_PROAGENCCODE',
                    columnName: '省联社机构代码',
                    columnType: '1',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        textboxEmptytext: ''
                    }
                },

                {// 下拉

                    formGroupName: '其它',
                    formGroupId: '',

                    entityId: 'ORG_DEPARTMENT',
                    columnId: 'ORGDEPARTMENT_MANAGEREGION',
                    columnName: '管辖区域',
                    columnType: '2',
                    formColumnRequired: 'N',
                    formColumnColSpan: 1,
                    formColumnRowSpan: 1,
                    formColumnWidth: '200px',
                    formColumnShowType: 'show',
                    columnTypeDetail: {
                        textboxCheckType: '',
                        textboxDataFromType: '',
                        textboxDataFromValue: '',
                        comboboxEmptytext: '-',
                        dictTypeCode: 'dict|COMPAREA',
                        comboboxMultiselect: 'Y',
                        comboboxShownullitem: 'N',
                        comboboxIsSearch: 'N'
                    }
                }

            ],
            dictColumn: {},
            columnObj: {},
            // 真正渲染的行
            rowColumn: [],
            // 表头
            colHeaders: [],
            // 真正渲染的数据
            trueTableDate: []
        }
    },
    async created() {
        this.dictColumn = this._.groupBy(this.showRowColumn, 'columnId')
        this.showRowColumn.forEach((item) => {
            this.columnObj[item.columnId.toUpperCase()] = item
        })
        // this._cardformInitData()
        this.$eventBus.$on('common-filter', (...args) => {
            // todo something
            console.log(args[0])
            this.commonFilter = args[0]
            this.commonFilterArr.forEach(item => {
                this.filterData[item] = this.commonFilter
            })
        }, this)
    },
    methods: {
        searchForm() {
            this._cardformInitData()
        },
        resetForm() {
            this.filterData = {
                DEPVPEOPLECOUNT_NUM: '',
                ORGDEPARTMENT_CNAME: '',
                ORGDEPARTMENT_DEPCODE: '',
                ORGDEPARTMENT_DEPGRADE: '',
                _INTERVAIL_MAX_ORGDEPARTMENT_CREATEDATE: '',
                _INTERVAIL_MIN_ORGDEPARTMENT_CREATEDATE: ''
            }
        },
        resize() {
            console.log('resize')
        },
        toggleSlider(val) {
            this.isOpen = !val
            this.defaultPercent = val ? 2 : 20
            // console.log(this.defaultPercent)
            this.$refs.split.onSetPercent(this.defaultPercent)
        },
        handleLeftTabClick(tab, event) {
            console.log(tab, event)
        },
        // 懒加载树节点数据
        loadNode(node, resolve) {
            console.log(node)
            if (node.level !== 0) {
                this.tree.ORGVORGANIZATION_ID = node.key
                this.tree.lv = node.level - 1
            }
            queryTreeSolution(17, 'ORGVORGANIZATION_ID', this.tree.ORGVORGANIZATION_ID, this.tree.lv)
                .then(res => {
                    res.forEach(item => {
                        item.isLeaf = !item.isParent
                    })
                    resolve(res)
                })
        },
        // 过滤树节点
        filterNode(value, data) {
            if (!value) return true
            return data.label.indexOf(value) !== -1
        },
        getFormColumnGuiType(type) {
            // console.log(type)
            return columnType[type].handsontable
        },
        // 操作高级查询
        handleHeightGrade(arr) {
            this.heightGrade = []
            arr.forEach((item, index) => {
                const temp = {
                    'formWhereJoinRule': 'and', // 连接方式 支持有“and 、or”
                    'leftBracket': '(', // 默认(
                    'formWhereColumnId': '21117', // 要查询字段的ID
                    'formWhereCpRule': 'like', // 条件方式 支持有“=、!=、like、 not like 、> 、>=、is null、is not null、in 、not in” 默认=
                    'formWhereValue': '部门', // 具有值
                    'formWhereSort': '', // 默认传入空字符串
                    'rightBracket': ')' // 默认)
                }
                if (item.operation === 'disjunction') {
                    temp.formWhereJoinRule = 'or'
                } else {
                    temp.formWhereJoinRule = 'and'
                }
                temp.formWhereColumnId = this.rowColumn[item.column].formColumnId
                item.conditions.forEach(item2 => {
                    if (item2.name === 'contains') {
                        temp.formWhereCpRule = 'in'
                        temp.formWhereValue = item2.args[0]
                    } else if (item2.name === 'not_contains') {
                        temp.formWhereCpRule = 'not in'
                        temp.formWhereValue = item2.args[0]
                    } else if (item2.name === 'empty') {
                        temp.formWhereCpRule = 'is null'
                        temp.formWhereValue = ''
                    } else if (item2.name === 'not_empty') {
                        temp.formWhereCpRule = 'is not null'
                        temp.formWhereValue = ''
                    } else if (item2.name === 'eq') {
                        temp.formWhereCpRule = '='
                        temp.formWhereValue = item2.args[0]
                    } else if (item2.name === 'neq') {
                        temp.formWhereCpRule = '!='
                        temp.formWhereValue = item2.args[0]
                    } else if (item2.name === 'begins_with' || item2.name === 'ends_with') {
                        temp.formWhereCpRule = 'like'
                        temp.formWhereValue = item2.args[0]
                    }
                    this.heightGrade.push(temp)
                })
            })
            console.log(this.heightGrade)
            this._cardformInitData(this.heightGrade)
        },
        _batchSaveButtonSave(data) {
            batchSaveButtonSave(this.formId, data)
                .then(res => {
                    console.log(res)
                    if (res.rcode === '0000') {
                        this.$message({
                            message: '数据修改成功',
                            type: 'success'
                        })
                        this._cardformInitData()
                    }
                })
        },
        handleRemoveRow(arr) {
            console.log(arr)
            console.log(this.trueTableDate)
            const changeData = {
                'formId': this.formId,
                'params': []
            }
            arr.forEach(item => {
                const temp = Object.assign({}, this.trueTableDate[item])
                changeData.params.push(temp)
            })
            removeData(changeData)
                .then(res => {
                    if (res.rcode === '0000') {
                        this.$message({
                            message: '数据删除成功',
                            type: 'success'
                        })
                        this._cardformInitData()
                    }
                })
        }
    }
}
</script>

